<?php

   class SolutionsAction extends CommonAction{
   	 private  $table_name;
   	 function __construct(){
   	 	
   	 	$this->table_name = "Solutions";
   	 	parent::__construct();
   	 }


   	  function  index(){


	               import('ORG.Util.Page');// 导入分页类

	               $count = M($this->table_name)->count();// 查询满足要求的总记录数 $map表示查询条件

                   $Page = new Page($count,C('PAGESIZE'));// 实例化分页类 传入总记录数

                   $show = $Page->show();// 分页显示输出

	               $list = M($this->table_name)->where($sql)->order('createtime DESC')->limit($Page->firstRow.','.$Page->listRows)->select();


                   $this->assign("list",$list);

                   $this->assign("page",$show);

                   $this->display();



   	  }

   	  
   	  //添加商品

   	  function  add(){
            if(isset($_POST['submit'])){
                 $data = $_POST;
                 $data['createtime']=mktime();
                 $data['status']=1;
                     
                 if(M($this->table_name)->add($data)){
                 	$this->success("操作成功！",U('index'));
                 }
            	 
            }else{
            	$this->list =M($this->table_name.'Cate')->select();
            	$this->display();
            }

   	  }


   	  function edit(){

         $id = is_numeric($_GET['id'])?intval($_GET['id']):exit();
         if(isset($_POST['submit'])){
         	$data = $_POST;
         	$data['createtime']=mktime();
         	if(M($this->table_name)->where("id=".$id)->save($data)){
         		$this->success("操作成功！",U('index'));
         	}
         }else{
         	$this->list =M($this->table_name.'Cate')->select();
         	$data =M($this->table_name)->where("id=".$id)->find();
         	$data['gps']=$data['gpsX'].','.$data['gpsY'];
         	$this->li =$data;
         	
         	$this->display();
         }
         

   	  }


   	  

     	 /**

  	  * 删除文章

  	  * 

  	  */

  	 function del(){

	         $qstr = $_GET['qstr'];

			if(isset($qstr)){

			   $arr=explode(",",$qstr);

			   $data=M($this->table_name);

			   foreach($arr as $val){

			     $data->where("id=$val")->delete();

			       

			   }

			   $this->success("删除成功！",__URL__."/index");

			

			}else{
               //如果不是批量删除
			   
			   $data ->where("id=".$_GET['id'])->delete();
			

			   $this->success("删除成功！",__URL__."/index");

			}

  	 }

   }



?>